package io.renren.modules.posinfo.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.renren.modules.cuttingcur.dao.CuttingmachineCurdataDao;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.posinfo.entity.PosinfoEntity;
import io.renren.modules.posinfo.service.PosinfoService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2023-02-09 19:07:37
 */
@RestController
@RequestMapping("posinfo/posinfo")
public class PosinfoController {
    @Autowired
    private PosinfoService posinfoService;

    @GetMapping("getPosInfo")
    public List<PosinfoEntity> getPosInfo(@RequestParam(value = "mid",required = false) String mid){
        return posinfoService.getPosInfo(mid);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("posinfo:posinfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = posinfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{mid}")
    @RequiresPermissions("posinfo:posinfo:info")
    public R info(@PathVariable("mid") String mid){
		PosinfoEntity posinfo = posinfoService.getById(mid);

        return R.ok().put("posinfo", posinfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("posinfo:posinfo:save")
    public R save(@RequestBody PosinfoEntity posinfo){
		posinfoService.save(posinfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("posinfo:posinfo:update")
    public R update(@RequestBody PosinfoEntity posinfo){
		posinfoService.updateById(posinfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("posinfo:posinfo:delete")
    public R delete(@RequestBody String[] mids){
		posinfoService.removeByIds(Arrays.asList(mids));

        return R.ok();
    }

}
